Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-analyzer: fix null pointer deref #14952

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

neheb
Copy link
Contributor

@neheb neheb commented Dec 10, 2024

I have:

@coveralls
Copy link

coveralls commented Dec 11, 2024

Pull Request Test Coverage Report for Build 12268281475

Details

  • 3 of 5 (60.0%) changed or added relevant lines in 1 file are covered.
  • 28 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+3.2%) to 64.756%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/packethandler.cc 3 5 60.0%
Files with Coverage Reduction New Missed Lines %
pdns/backends/gsql/gsqlbackend.hh 1 97.71%
pdns/dnsdistdist/dnsdist.hh 1 84.24%
pdns/pollmplexer.cc 1 83.66%
pdns/tcpiohandler.cc 2 68.18%
modules/lmdbbackend/lmdbbackend.cc 2 73.45%
pdns/packethandler.cc 4 72.45%
pdns/signingpipe.cc 5 83.38%
ext/json11/json11.cpp 12 62.72%
Totals Coverage Status
Change from base Build 12257697323: 3.2%
Covered Lines: 125906
Relevant Lines: 163530

💛 - Coveralls

@miodvallat
Copy link
Contributor

I am not sure these changes are correct. getSOAUncached may end up invoking getSOA and set db to a valid pointer.

On the other hand, regardless of whether this call succeeds or not, a final nullptr check for s_db.db should be done to exit before the rest of the logic runs.

In other words:

  if (s_db.db == nullptr) {
    ... existing code unchanged ...
  }

  if (s_db.db == nullptr)
    return;

  ... rest of the logic here

@dwfreed
Copy link
Contributor

dwfreed commented Dec 11, 2024

That's not necessary, as UeberBackend::getSOAUncached will only return true if db gets set to a valid pointer (which is handled by DNSBackend::getSOA). This entire PR is just wrong and fails to understand how this code works; this section needs no changes.

@miodvallat
Copy link
Contributor

Then maybe adding a simple assert(s_db.db != nullptr) line would hint the static analyzer that the pointer is valid at this point.

@mind04
Copy link
Contributor

mind04 commented Dec 11, 2024

After the forced push, this pull is reduced to a bad behavior change. Resulting in a huge performance hit and potentially broken NSEC responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants